package com.test.demoapp.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.test.demoapp.R
import com.test.demoapp.base.BaseActivity
import com.test.demoapp.entity.RespVo
import java.text.SimpleDateFormat
import java.util.*

class HisAdapter() : BaseQuickAdapter<RespVo, BaseViewHolder>(R.layout.item_home) {
    override fun convert(helper: BaseViewHolder, item: RespVo) {
        val position = helper.adapterPosition
        if (position == 0) {
            helper.setText(
                R.id.tv_content,
                "最新时间：" + item.time?.toLong()?.let { transferLongToDate(it) }
            )
            helper.setTextColor(R.id.tv_title, Color.RED)
        } else {
            helper.setTextColor(R.id.tv_title, Color.parseColor("#FF424242"))
            helper.setText(
                R.id.tv_content,
                "请求时间：" + item.time?.toLong()?.let { transferLongToDate(it) }
            )
        }
        helper.setText(R.id.tv_title, item.authorizations_url)
    }

    companion object {
        fun transferLongToDate(millSec: Long): String {
            val sdf = SimpleDateFormat("MM-dd HH:mm:ss")
            val date = Date(millSec)
            return sdf.format(date)
        }
    }
}